PREFIX=arm-linux-gnueabihf-
CC=$(PREFIX)gcc
LD=$(PREFIX)ld
AR=$(PREFIX)ar
OBJCOPY=$(PREFIX)objcopy
OBJDUMP=$(PREFIX)objdump

led.img : start.s led.c main.c
	$(CC) -nostdlib -c -g start.s -o start.o
	$(CC) -nostdlib -c -g led.c -o led.o
	$(CC) -nostdlib -c -g main.c -o main.o
	$(LD) -g start.o led.o main.o -Ttext 0X80100000 -o led.elf
	$(OBJCOPY) led.elf -O binary -S led.bin
	$(OBJDUMP) -D -m arm led.elf > led.dis
	mkimage -T imximage -n ./tools/imximage.cfg.cfgtmp -e 0x80100000 -d led.bin led.imx
	dd if=/dev/zero of=1k.bin bs=1024 count=1
	cat 1k.bin led.imx > led.img

clean:
	rm -rf *.o led.bin led.elf led.dis led.imx led.img